home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-06-30 | 42.6 KB | 1,180 lines |
- C.S.M.P. Digest Thu, 14 May 92 Volume 1 : Issue 80
-
- Today's Topics:
-
- How to convince Mac+ it has 6-meg of RAM ?????????
- Anybody using MS DDE AppleEvents?
- Summary of Graf3D (long...)
-
-
- The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
-
- These digests are available (by using FTP, account anonymous, your email
- address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon.
- edu. This is also the home of the comp.sys.mac.programmer Frequently Asked
- Questions list. The last several issues of the digest are available from
- sumex-aim.stanford.edu as well.
-
- These digests are also available via email. Just send a note saying that you
- want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
- automatically receive each new digest as it is created.
-
- The digest is a collection of articles from the internet newsgroup comp.sys.
- mac.programmer. It is designed for people who read c.s.m.p. semi-regularly
- and want an archive of the discussions. If you don't know what a newsgroup
- is, you probably don't have access to it. Ask your systems administrator(s)
- for details. (This means you can't post questions to the digest.)
-
- The articles in these digests are taken directly from comp.sys.mac.programmer.
- They are not edited; all articles included in this digest are in their original
- posted form. The only articles that are -not- included in these digests are
- those which didn't receive any replies (except those that give information
- rather than ask a question). All replies to each article are concatenated
- onto the original article in the order in which they were received. Article
- threads are not added to the digests until the last article added to the
- thread is at least one month old (this is to ensure that the thread is dead
- before adding it to the digests).
-
- Send administrative mail to mkelly@cs.uoregon.edu.
-
- -------------------------------------------------------
-
- From: sietze@tardis.et.tudelft.nl (;Sietze Schukking)
- Subject: How to convince Mac+ it has 6-meg of RAM ?????????
- Date: 10 Apr 92 10:11:10 GMT
- Organization: Delft University of Technology, Dept. of Electrical Engineering
-
- Hello, again yesterday I posted the following message to comp.sys.mac.system
- and got some responces by mail and saw a follow up which pointed out that i
- probably did not make myself clear enough and maybe addressed the wrong group,
- this was the original posting:
-
- In article <1992Apr09.100610.20514@donau.et.tudelft.nl>, sietze@tardis.et.tudelf
- t.nl (;Sietze Schukking) writes:
- |> Hello, I have a question:
- |>
- |> What software must be patched and how to tell a Mac+ that
- |> it has more than 4meg of RAM.
- |> The Ram is placed for example between 6 and 8 megabytes,
- |> the hardware is no problem, there is room and i can do that,
- |> but to use it the software must be patched by an INIT (EX) or
- |> program or something.
- |>
- |> So can anybody tell me if this has been done before or
- |> what one has to do to get this working.
- |>
- |> Many thanks
- |>
- |> Sietze Schukking
- |>
- |> sietze@tardis.et.tudelft.nl
- |>
- Well I know the SIMM sockets only except 256kb and 1Mb SIMM's, so maximum
- is 4Mb regular. But the address space of the MC68000 processor is 16Mbytes,
- partly this is occupied by memory and other peripherals. I have experience
- with this hardware as i made a memory extention board to extend my 512KE to
- 4Mbyte and you can add a memory expansion board to the processor rather
- simply. This board would for example insert 2 megB of RAM between address
- 6meg and 8meg.
-
- So now the problem again what must i do to let the Mac+ use it?
-
- Somebody suggested something like patching some kind of free memory structure
- to fake the system into believing it got 8megByte of memory with a non
- relocatable block between 4meg and 6meg ( where the ROM's and SCSI are located)
-
- I think it is possible (in hardware) to extend the memory configuration of a
- Mac+ to 7,5 megB.
-
- As you can see I am a hardware person and not to deep into software so please
- help me out.
-
- Thanks again
-
- Sietze Schukking
-
- sietze@tardis.et.tudelft.nl
-
- +++++++++++++++++++++++++++
-
- From: stoodt@cis.umassd.edu (Michael Stoodt)
- Date: 10 Apr 92 18:43:20 GMT
- Organization: University of Massachusetts Dartmouth
-
- In <1992Apr10.101110.4234@donau.et.tudelft.nl> sietze@tardis.et.tudelft.nl (;Sietze Schukking) writes:
- >.... This board would for example insert 2 megB of RAM between address
- >6meg and 8meg.
-
- >So now the problem again what must i do to let the Mac+ use it?
-
- >Somebody suggested something like patching some kind of free memory structure
- >to fake the system into believing it got 8megByte of memory with a non
- >relocatable block between 4meg and 6meg ( where the ROM's and SCSI are located)
-
- >I think it is possible (in hardware) to extend the memory configuration of a
- >Mac+ to 7,5 megB.
-
- >As you can see I am a hardware person and not to deep into software so please
- >help me out.
-
- You're not going to be able to do this without getting deep into the
- software, fiddling around with the Memory Manager's data structures
- and patching its calls at init time. And what you'll get as a result
- will be fragmented memory; even if you can convince the Memory Manager
- that it's ok for it to have this massive immovable block in the middle
- of its space, then (assuming you're running Multifinder or System 7)
- an application will be able to access either the bottom part (the
- under-4MB area) or the top part (your add-on), but not both, because
- the heap the Memory Manager creates for it will have to be contiguous.
- (And you won't be able to control in which area the application goes,
- either, except by launching them in a certain order - application
- heaps are allocated top-down - or by making the application request
- too much memory to fit in the smaller of the two parts (note that the
- system heap is at the bottom of memory, so the bottom part might have
- less space available than the top if the system heap is large
- enough).)
-
- There comes a point where one says, "this is too much trouble; time to
- go out and buy an LC or better"; I think you're probably close to it.
-
- Michael Stoodt
-
- +++++++++++++++++++++++++++
-
- From: jimc@isc-br.ISC-BR.COM (Jim Cathey)
- Date: 13 Apr 92 20:46:14 GMT
- Organization: ISC-Bunker Ramo, An Olivetti Company
-
- In article <1992Apr10.101110.4234@donau.et.tudelft.nl> sietze@tardis.et.tudelft.nl (;Sietze Schukking) writes:
- >This board would for example insert 2 megB of RAM between address
- >6meg and 8meg.
- >
- >So now the problem again what must i do to let the Mac+ use it?
- >
- >Somebody suggested something like patching some kind of free memory structure
- >to fake the system into believing it got 8megByte of memory with a non-
- >relocatable block between 4M and 6M (where the ROM's and SCSI are located).
-
- I tried something like this once. Back in the days of old, I put a 1
- MB bank of RAM into my 512KE. This was for a non-volatile RAM-disk
- that wouldn't go away when the system crashed (which I used for my
- Aztec C development work). Worked like a charm --- the normal system
- didn't notice this extra RAM (which I think hid at the 2M point,
- somewhere the auto-sizing startup code didn't find it). And, it was
- damned FAST! However, there were times when I wanted to have more main
- memory and forgo the RAM disk. So, I wrote an application (for
- Unifinder & System 3.2 days) that moved the application heap to this
- extra bank of RAM. The system heap (and the video [of course] and all
- INIT-allocated RAM) stayed where it was, so I had a bigger than Mac+
- sized heap to run in. I remember I didn't have to change all that many
- low-memory variables to make this work (half a dozen or less). I
- certainly didn't have to patch any traps, nor write any INITs, nor do
- any other ugly stuff. I just moved one memory zone (that was ugly
- enough, I'm sure).
-
- Everything worked, except (of course) Microsoft applications. And only
- because they refused to follow the rules (anybody remember the 1MB
- address-range limit of their early P-code interpreter?)
-
- At the time I wanted to make a unified application heap, that put a
- large, fictitious non-relocatable block in there so I could continue
- to use the space of the former application heap, but I never got that
- working. It wasn't vital, so I skipped it. I would probably have
- had to patch a trap to do this, so InitApplZone (or whatever) would
- invent this bogus block.
-
- All this stuff died a flaming death with Multifinder, not surprisingly.
- What was surprising was how new a system it would work with if I used
- Finder. I'm not sure, but I think I remember even one of the System 6
- variants would work with it. If not, certainly it was System 4 or
- System 5 that did still work. Anyway, in order to run MF I redesigned
- my memory interface with a switch, so I could get a plain 1MB Mac+
- view of memory and leave the extra 512K in the ozone, or else the
- original situation. This is what my home Mac uses to this day. It's
- been quite a while since I threw the RAMdisk switch. Anymore nothing
- will fit on a 1MB 'disk', nor will much interesting in the way of a
- development environment run well in 1/2M of heap.
-
- In effect, development today is much slower than it was a few years
- ago. Fortunately I don't really do any at home.
-
- +----------------+
- ! II CCCCCC ! Jim Cathey
- ! II SSSSCC ! ISC-Bunker Ramo
- ! II CC ! TAF-C8; Spokane, WA 99220
- ! IISSSS CC ! UUCP: uunet!isc-br!jimc (jimc@isc-br.isc-br.com)
- ! II CCCCCC ! (509) 927-5757
- +----------------+
- "PC's --- the junk bonds of the computer industry"
-
- ---------------------------
-
- From: ba0k+@andrew.cmu.edu (Brian Patrick Arnold)
- Subject: Anybody using MS DDE AppleEvents?
- Date: 9 Apr 92 12:00:47 GMT
- Organization: Carnegie Mellon, Pittsburgh, PA
-
-
- Hello there,
-
- is anybody reading this implementing Microsoft's DDE AppleEvents in
- their applications? If you're from Microsoft and if you have any
- concern at all about a reputation for service, you're also encouraged to
- give me a reply.
-
- It seems that nobody on the net (netnews comp.sys.mac.programmer,
- comp.ms.windows and comp.ms.windows.programmer) is implementing DDE in
- their app, save a fellow trying to use the Excel DDE Macros with a
- program called CCalc. Or at least nobody knows how to answer the
- questions I've posted more than a week ago to these places.
-
- Naturally, you'd assume I'd try to call Microsoft to get some
- answers. I happened to call several of Microsoft's byzantine phone
- numbers:
-
- Microsoft Excel Developer Program (800) 227-6444 dept ET
- (no longer in service, must call the following:)
- Microsoft Sales (800) 227-4679
- (busy twice today, twice yesterday.)
- Microsoft Product Support Services (206) 454-2030
- (forwarded to Excel Support:)
- Microsoft Excel Support (206) 454-7080
-
- The last number answered my call after I spent 2 minutes realizing the
- automated hierarchical "hit a button..." service was a complete waste of
- my time. After being on hold for several minutes listening to the
- rocking "on hold" jazz station, I was transferred to another person (I
- think it was Sales) who put me on hold for several more minutes until
- they told me they would call me back after looking into my question
- (which was "can anybody answer a couple of questions I have about
- Macintosh DDE AppleEvents?")
-
- Do I have to buy an Excel Developer Kit to get a decent answer? I
- naturally assume Microsoft doesn't want to help anyone who isn't paying
- for their assistance in generating more revenues, so I figure I must buy
- this kit before I can get a decent reply to my questions.
-
- Well, I'm pissed and I think this is absurd. I need answers today, not
- next month.
-
- - - Brian
-
- +++++++++++++++++++++++++++
-
- From: breidenb@Informatik.TU-Muenchen.DE (Oliver Breidenbach)
- Organization: Technische Universitaet Muenchen, Germany
- Date: Fri, 10 Apr 1992 10:11:10 GMT
-
-
- In article <sdt_9jC00UhWM6614h@andrew.cmu.edu>, Brian Patrick Arnold <ba0k+@andrew.cmu.edu> writes:
-
- |> Well, I'm pissed and I think this is absurd. I need answers today, not
- |> next month.
-
- This is not absurd, this is Microsoft.
- I seem to recall, that DDE is something like Publish and Subscribe in Windows
- 3.x perhaps you should refer to the Windows Reference material.
-
- I once bought MS Word 4.0 for the Mac. I sent in my registration card
- and now I keep getting all those nifty Windows 3.x informations and
- everything about the PC products (I even got an invitation for the Windows
- 3.0 rollout event) and how I can upgrade to their newest versions, but I
- never got any information that there have been several bugfix releases of the
- Word 4.0 (Mac) nor have I heard about Word 5 (Mac) and how to upgrade to it.
-
- Call this absurd.
-
- Cheers,
-
- Oliver.
-
- ---------------------------
-
- From: howard@rigel.cs.pdx.edu (howard l. berkey)
- Subject: Summary of Graf3D (long...)
- Date: 7 Apr 92 16:49:43 GMT
-
-
-
- I should have made this available for the c.s.m.p. digest...
- Have fun!
-
-
-
-
-
- - -----------------------press n now if not interested------------------------
-
-
-
-
-
-
-
- Here's all the info I have to date...Good Luck!
- -Howard
-
-
-
-
- >From lasleyse@wam.umd.edu Sat Feb 29 17:21:00 1992
- Received: from wor-srv.wam.umd.edu by rigel.cs.pdx.edu (4.1/pdx-client-evision: 1.17
- id AA27848; Sat, 29 Feb 92 17:20:48 PST
- Received: from rac2.wam.umd.edu by wor-srv.wam.umd.edu
- id <AA05078@wor-srv.wam.umd.edu>; Sat, 29 Feb 92 20:20:35 -0500
- From: Scott E. Lasley <lasleyse@wam.umd.edu>
- Received: by rac2.wam.umd.edu
- id <AA09693@rac2.wam.umd.edu>; Sat, 29 Feb 92 20:20:35 -0500
- Date: Sat, 29 Feb 92 20:20:35 -0500
- Message-Id: <9203010120.AA09693@rac2.wam.umd.edu>
- To: howard@rigel.cs.pdx.edu
- Subject: Re: Graf3D
- Newsgroups: comp.sys.mac.programmer
- In-Reply-To: <4906@pdxgate.UUCP>
- Organization: Space Physics Group, University of Maryland at College Park
- Status: OR
-
- i think that Graf3D is documented in the MPW manual. Here is some info
- from the net regarding Graf3D:
-
-
- Path: wam!haven!uflorida!uakari.primate.wisc.edu!sdd.hp.com!wuarchive!kuhub.cc.ukans.edu!mlab2
- From: mlab2@kuhub.cc.ukans.edu
- Newsgroups: comp.sys.mac.programmer
- Subject: Graf3D and What I Discovered ThereIn - part 1
- Message-ID: <27086.27515590@kuhub.cc.ukans.edu>
- Date: 26 Nov 90 23:49:04 GMT
- Organization: University of Kansas Academic Computing Services
- Lines: 116
-
- Some UseNetter's thought this might be beneficial to the net, so, here goes the
- first installment of "Graf3D and What I Discovered Therein." Feel free to
- correct and dispute anything I say. I'm not an expert programmer and only
- stumbled through Graf3D a year and a half ago. Also, sorry, I don't know C.
-
- "Graf3D and What I Discovered Therein - Part1"
- ==============================================
- Here are the following functions/procedures and data types that Graf3D defines:
-
- Data Types:
- Fixed (Essentially a LongInt <32-Bit> number where the high 16 bits
- represent the integer portion of the number and the low 16 bits
- represent the fractional portion of the number. HiWord and LoWord
- can be used to extract said portions. To convert a LongInt to a
- Fixed type, divide the LongInt by 65536 <2^16>)
-
- Point3D = RECORD
- x:Fixed;
- y:Fixed;
- z:Fixed;
- END;
- (Note: Unlike the Point type, h and v are called x and y <and z>
- and are of type Fixed instead of Integer.)
-
- Point2D = RECORD
- x:Fixed;
- y:Fixed;
- END;
- (Note: Why a Point2D and not just Point? a- It uses the Fixed type
- variable, and b- It is thus easy to convert between a Point3D and
- Point2D for screen display.)
-
- XfMatrix = ARRAY [0..3, 0..3] of Fixed;
- (This is the transformation matrix that Graf3D uses to rotate and
- translate points. If your familiar with the concepts and lingo
- used in 3D graphics, you'll know all about the transformation
- matrix.)
-
- Port3DPtr = ^Port3D;
- Port3D = RECORD
- GrPort: GrafPtr;
- viewRect: Rect;
- xLeft, yTop, xRight, yBottom: Fixed;
- pen, penPrime, eye: Point3D;
- hSize, vSize: Fixed;
- hCenter, vCenter: Fixed;
- xCotan, yCotan: Fixed;
- ident: Boolean;
- xForm: XfMatrix;
- END;
-
- (I'll discuss each of these fields to the Port3D in the next
- installment.)
-
- (Functions and Procedures)
-
- PROCEDURE InitGraf3D (GlobalPtr: Ptr);
-
- PROCEDURE Open3DPort (port: Port3DPtr);
-
- PROCEDURE SetPort3D (port: Port3DPtr);
-
- PROCEDURE GetPort3D (VAR port: Port3DPtr);
-
- PROCEDURE MoveTo2D (x, y: Fixed);
-
- PROCEDURE MoveTo3D (x, y, z: Fixed);
-
- PROCEDURE Move2D (dx, dy: Fixed);
-
- PROCEDURE Move3D (dx, dy, dz: Fixed);
-
- PROCEDURE LineTo2D (x, y: Fixed);
-
- PROCEDURE LineTo3D (x, y, z: Fixed);
-
- PROCEDURE Line2D (dx, dy: Fixed);
-
- PROCEDURE Line3D (dx, dy, dz: Fixed);
-
- FUNCTION Clip3D(src1, src2: Point3D; VAR dst1, dst2: Point);
-
- PROCEDURE SetPt3D (VAR pt3D: Point3D; x, y, z: Fixed);
-
- PROCEDURE SetPt2D (VAR pt2D: Point2D; x, y: Fixed);
-
- PROCEDURE ViewPort (r: Rect);
-
- PROCEDURE LookAt (left, top, right, bottom: Fixed);
-
- PROCEDURE ViewAngle (angle: Fixed);
-
- PROCEDURE Identity;
-
- PROCEDURE Scale (xFactor, yFactor, zFactor: Fixed);
-
- PROCEDURE Translate (dx, dy, dz: Fixed);
-
- PROCEDURE Pitch (xAngle: Fixed);
-
- PROCEDURE Yaw (yAngle: Fixed);
-
- PROCEDURE Roll (zAngle: Fixed);
-
- PROCEDURE Skew (zAngle: Fixed);
-
- PROCEDURE Transform (src: Point3D; VAR dst: Point3D);
-
- Whew! That's it. Most of this has come straight from the MPW documentation.
- I'll discuss each of these in following installments. For now, you might note
- that many of these have direct QuickDraw counterparts (SetPt, InitGraf, etc...)
- that should make many of the procedures and functions almost self explanatory.
-
- Well, all for now!
-
- john calhoun
-
-
- Path: wam!haven!udel!wuarchive!kuhub.cc.ukans.edu!mlab2
- From: mlab2@kuhub.cc.ukans.edu
- Newsgroups: comp.sys.mac.programmer
- Subject: Grad3D and What I Discovered Therein - part 2
- Message-ID: <27110.2752a9ea@kuhub.cc.ukans.edu>
- Date: 28 Nov 90 00:01:13 GMT
- Organization: University of Kansas Academic Computing Services
- Lines: 97
-
- Graf3D and What I Discovered Therein - part 2
-
- Yeah, part 1 was pretty much header info. But, some people may not have it.
- Yes, I will present some code for setting up the 3D port and using it. Wait
- until about part 4 or 5 or so. This is preliminary stuff to avoid a lot of
- confusion later.
-
- The only variable type I skipped over last time was the Port3D record. Here it
- is described:
-
- Fields of the Port3D;
- GPort This is also documented as GrPort in the MPW docs. In any event
- it is a pointer to the grafPort associated with the 3D port. Thus
- standard Quickdraw calls to this port will show up with the 3D
- calls. Want your 3D to appear white on black? You can just
- InvertRect the portRect field of the G(r)Port field of your Port3D.
-
- viewRect Viewing rectangle within the grafPort. In the 3D-way of describ-
- ing a 'point of view', this rectangle corresponds to the base of
- the pyramid formed by the user's "eye" and the four corners of the
- screen.
-
- xLeft, World coordinates corresponding to the viewRect. You shouldn't
- yTop, have to manipulate these variables directly. The procedures for
- xRight, setting up the camera take care of these.
- yBottom
-
- pen Like the Quickdraw pen, but with 3 dimensional coordinates.
-
- penPrime The pen location as transformed by the xForm matrix. Thus, calls
- to Yaw, Roll, etc will affect this pen's location. Again, you
- shouldn't have to manipulate this variable.
-
- eye When you call ViewAngle, this variable is established. It repres-
- ents the 3D point in space where the apex of the viewing pyramid
- is fixed.
-
- hSize, This will store the half-width and half-height of the viewRect in
- vSize screen coordinates.
-
- hCenter, Center of the viewRect in screen coordinates.
- vCenter
-
- xCotan, Graf3D sets these up as viewing cotangents (when you call ViewAngle)
- yCotan for calls to Clip3D.
-
- Ident When TRUE, the transforming routines are skipped. This is set to
- TRUE when you set the xForm matrix to the identity matrix (non-
- rotated).
-
- xForm This is a 4x4 matrix of variables for transforming points. All
- calls to Yaw(), Roll(), etc are applied to this matrix and then
- Graf3D uses the matrix to transform points in space. Unless
- reset by Identity, this matrix will continue to represent the net
- result of all transformation calls.
-
- Setting up a port:
- As with programs using Quickdraw, a call to IntGraf3D(@thePort3D) must be made
- during the initialization portion of your program. Here is how I've
- initialized my 3D port:
-
- var
- gPort3D :Port3D;
- gPort3DPtr :Port3DPtr;
- origin :Point3D;
- viewScreen :Rect;
-
- begin
- InitGraf3D(@thePort3D);
- Open3DPort(@gPort3D);
- SetRect(viewScreen,100, 20, 348, 144);
- ViewPort(viewScreen);
- LookAt(-983040, 655360, 983040, -655360);
- ViewAngle(1604480);
- SetPt3D(origin, 0, 0, 0);
- gPort3D.eye:= origin;
- FillRect(gPort3D.viewRect, black);
- ...
- end;
-
- This will set up a small 248x124 3D port in the center of a 7-inch Mac screen.
- As well, it sets the eye at the 'origin' in space looking straight ahead
- parallel to the "ground". Finally it fills it black to look like outer space.
- Those lengthy numbers used in LookAt and ViewAngle are fixed type numbers. The
- ViewAngle (1604480) for example, represents an angle of 24 degrees
- (1604480/65536).
- Perhaps this is a good time to explain the view angles. The view angle defines
- the amount of perspective given to 3D points and lines when drawn to the
- screen. An angle of 0 represents no perspective (or orthographic) projection.
- 10 degrees is similar to the perspective seen through a telephoto lens, 25
- degrees is generally accepted as 'normal' perspective of the human eye, and 80
- degree would give you a distorted 'fisheye'-like wide angle perspective.
-
- Enough of Part 2. Stay tuned for more. Note: I can't get MAIL to work right.
- I can READ but can't reply.
-
- john calhoun
-
-
- Path: wam!haven!ames!rex!wuarchive!kuhub.cc.ukans.edu!mlab2
- From: mlab2@kuhub.cc.ukans.edu
- Newsgroups: comp.sys.mac.programmer
- Subject: Graf3D and What I Discovered Therein - part 3
- Message-ID: <27177.2756a557@kuhub.cc.ukans.edu>
- Date: 1 Dec 90 00:30:47 GMT
- Organization: University of Kansas Academic Computing Services
- Lines: 162
-
- Graf3D and What I Discovered Therein - part3
-
- Well, I must say I'm posting this all a piece at a time. I don't have any of
- this written all out in one place. So if you want this, here it is, capture
- it. Also, I'll say again that I am not an expert with this at all. I have
- only experimented with it for a couple of months back when I was first learning
- to program the Mac (and learning Pascal too). So, feel free to post
- corrections of any of my errors and take my 'tutorial' as a starting point
- only. I just saw all the confusion about Graf3D and thought, "Well, I could
- explain a little bit of it."
-
- Drawing in 3D-
-
- As I may have hinted at before, all drawing is done 'wireframe' with Graf3D.
- You set up a group of 3D points and use Move3D, MoveTo3D, LineTo3D, etc. to
- display your drawing. I'm sure a guru could take the 2D equivalents of these
- screen points and create regions and paint them etc. For my own purposes, this
- would clearly have been too slow.
-
- So, how did I optimize Graf3D within the bounds allowed by Graf3D?
-
- Setting up your 3D points-
-
- Consider a simple cube. Counting up the vertices gives us 8 points. If we set
- up an array [0..7] of Point3D, we can initialize all these points and then
- repeatedly connect-the-dots. Calls to Yaw, Pitch, etc, and moving the 'eye'
- around in space will give us different views of this simple cube.
-
- The scale you use for the cube is fairly arbitrary. Lets use a cube with a
- side of length 100 for simplicity. In your initialization routine you caould
- call this:
-
- var
- cubeVertices: array [0..7] of Point3D;
-
- begin
- SetPoint3D(cubeVertices[0], 0, 0, 0);
- SetPoint3D(cubevertices[1], 100, 0, 0);
- SetPoint3D(cubeVertices[2], 100, 100, 0);
- SetPoint3D(cubeVertices[3], 0, 100, 0);
- SetPoint3D(cubeVertices[4], 0, 0, 100);
- SetPoint3D(cubeVertices[5], 100, 0, 100);
- SetPoint3D(cubeVertices[6], 100, 100, 100);
- SetPoint3D(cubeVertices[7], 0, 100, 100);
- ...
- end;
-
- An alternate (and perhaps quicker) way of doing this would be to have set up an
- array of Fixed [0..7, 0..2]. This way, you never create the 3D points, but
- assign the x, y, and z coordinates of each verticee. MoveTo3D and LineTo3D
- (etc) expect you to pass the fixed x, y, and z coordinates anyway. Using
- Point3D's is convenient, but you'll still have to "dissect" the corrdinates out
- of these points when you call MoveTo3D, etc.
-
- A 'convenient' way around this hassle would be to create your own procedures:
- As an example:
- Long way:
-
- MoveTo3D(cubeVertices[i].x, cubeVertices[i].y, cubeVertices[i].z);
-
- A nice procedure:
-
- procedure MoveTo3DPt (thePoint: Point3D);
- begin
- MoveTo3D(thePoint.x, thePoint.y, thePoint.z);
- end;
-
- -now simply call-
- MoveTo3DPt(cubeVertices[i]);
-
- I think I'll use this second way here. (You could make a whole library of
- routines that translate 3D points, etc.)
- So, you've set up your 3D port (from part 2 of this little piece), and you've
- initialized the 8 vertices of your cube, - here is a simple loop to use the
- mouse to rotate the points from the perspective of the eye.
-
- var
- mousePt:Point; {A STANDARD QuickDraw point that is}
-
- {------}
-
- procedure MoveTo3DPt (thePoint: Point3D);
- begin
- MoveTo3D(thePoint.x, thePoint.y, thePoint.z);
- end;
-
- {------}
-
- procedure LineTo3DPt (thePoint: Point3D);
- begin
- LineTo3D(thePoint.x, thePoint.y, thePoint.z);
- end;
-
- {------}
-
- begin
-
- ...
-
- repeat
- GetMouse(mousePt);
- Roll((256 - mousePt.h) * 3276); {3276 is about 1/10 of a degree, thus
- on a 512 Mac screen, +/- 25 degrees
- is your roll velocity}
- origin.z:=origin.z+mousePt.v; {We'll use the vertical position of the
- mouse to change the z coordinate of
- the origin (see part 2 for origin}
- gPort3D.eye:=origin; {Now we set the 'eye' of the 3D port
- to the new location of the var origin}
- FillRect(gPort3D.ViewRect, black); {Erase other points drawn}
- MoveTo3DPt(cubeVertices[0]);
- LineTo3DPt(cubeVertices[1]);
- LineTo3DPt(cubeVertices[2]);
- LineTo3DPt(cubeVertices[3]);
- LineTo3DPt(cubeVertices[0]);
- {We have just drawn the bottom of the cube}
- MoveTo3DPt(cubeVertices[4]);
- LineTo3DPt(cubeVertices[5]);
- LineTo3DPt(cubeVertices[6]);
- LineTo3DPt(cubeVertices[7]);
- LineTo3DPt(cubeVertices[4]);
- {We have now drawn the top of the cube, now to connect the top & bot}
- MoveTo3DPt(cubeVertices[0]);
- LineTo3DPt(cubeVertices[4]);
- MoveTo3DPt(cubeVertices[1]);
- LineTo3DPt(cubeVertices[5]);
- MoveTo3DPt(cubeVertices[2]);
- LineTo3DPt(cubeVertices[6]);
- MoveTo3DPt(cubeVertices[3]);
- LineTo3DPt(cubeVertices[7]);
- until button; {clicking the mouse button exits the program}
- end.
-
- So, try that one out. It's bits from a little test program I wrote. You'll
- also have to have part 2 of my posts to do the port setting up stuff. I'm
- hoping to that this is enough to get most everyone started.
-
- I could post more, but mostly program specific stuff. I will say that my
- biggest annoyance with Graf3D was that it is difficult (impossible?) to
- actually rotate both the cube AND the eye at the same time. As I recall,
- rotation calls to Yaw and the like actually rotate space about the point
- (0,0,0). If you have, for example, two cubes located in differnt places in
- space, calls to pitch will rotate BOTH cubes teeter-totter like about the point
- (0,0,0) of space. I could only imagine setting up SEPERATE 3D grafports for
- each cube and copybitting the two (via XOr) to a single 2D grafport on the
- screen. Slow.
-
- If anyone has any questions, post them to the net (or mail me I suppose). I
- can't reply to mail sent to me, but I could post more on a particular aspect of
- Graf3D to the net.
-
- One person mailed me about rotating 3D waveforms and displaying them. That
- would probably be fairly easy to do given the code I've posted. Define the
- waveform as a chain of 3D points stretching across the point (0,0,0). Move the
- eye out away from (0,0,0) but look TOWARD the center of space. Yaws and Rolls
- will gimble the waveform about. Redraw (point to point) the waveform after
- each transformation. You can scale the waveform by simply moving the eye of
- the 3D port toward and away from the center of space.
-
- Cheerio. I'll check the net for requests.
-
- john calhoun
-
-
- Path: wam.umd.edu!ni.umd.edu!haven.umd.edu!ames!ncar!hsdndev!wysocki@husc.harvard.edu
- From: wysocki@husc.harvard.edu (Chris Wysocki)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Think C 5.0, Apple libs and Graf3D
- Message-ID: <96@hsdndev.UUCP>
- Date: 4 Dec 91 03:20:41 GMT
- References: <1991Dec4.005525.13637@ux1.cso.uiuc.edu>
- Sender: usenet@hsdndev.UUCP
- Organization: Harvard University, Cambridge, MA
- Lines: 399
-
- In article <1991Dec4.005525.13637@ux1.cso.uiuc.edu>, databoy@mrcnext.cso.uiuc.edu
- (John Snook) writes:
-
- > Ok, I've got the 5.0 vers, new libs. I'm looking in :Mac Libraries: and I find
- > "Graf3D". I'm thinking "oh boy oh boy". I look at the header file in headers:
- > apple headers:, Graf3D.h, and I'm thinking "oh shit".
- > Any Docs, Suggestions or recomendations would be greatly appreciated.
-
- Here's some pseudo-documentation for Graf3D, as well as a couple of sample
- programs. I believe that the Graf3D routines are also documented in one of the
- MPW manuals.
-
- Chris Wysocki
- wysocki@husc.harvard.edu
-
- - --------
- Graf3D: The Three-dimensional Graphics Library
-
- Graf3D draws three dimensional graphics in the two-dimensional environment
- provided by Quickdraw.
-
- Graf3D presents a "camera-eye view" of the objects drawn. With Graf3D
- procedures, the programmer sets the camera's location and field-of-view,
- as well as the location and orientation of the object being viewed. Graf3D
- manages a "viewing pyramid" whose apex is at the camera's eye and whose base is
- Graf3D's "ViewPort". The Graf3D package will clip objects being viewed to this
- pyramid.
-
- The Graf3D package makes extensive use of the "fixed point" data type. "Fixed"
- is defined as:
- type
- fixed = longint;
- The high order word of a fixed variable is the integer part; the low order
- word is the fraction part. Values are represented in units of 1/65536ths. For
- example, the number 2.5 would be represented by a "2" in the high word and a
- 32768 in the low order word (32768/65536 = .5), which would yield the longint
- value 163840. Another way to think of it is that the value of a "fixed"
- variable is the value of the longint divided by 65536. For more detail see
- Inside Macintosh in the "Introduction to Memory Management" chapter.
-
-
- Graf3D Types
-
- Point3D
- A Point3D is a record containing three "fixed" coordinates.
-
- Point3D = record
- x : fixed;
- y : fixed;
- z : fixed;
- end;
-
- Point2D
- A Point2D is a record containing two "fixed" coordinates.
-
- Point2D = record
- x : fixed;
- y : fixed;
- end;
-
-
- XfMatrix
- An XfMatrix is a 4x4 matrix of "fixed" values that holds the transformation
- equation for points to be viewed.
-
- XfMatrix = array [0..3, 0..3] of fixed;
-
- Port3D
- The Port3D contains all of the state variables necessary to map the three
- dimensional coordinates of the image into the two dimensional screen coordinates.
- "GrPort" is the pointer to the QuickDraw grafPort associated with this Port3D.
- "viewRect" is the viewing rectangle within the Port3D. "xLeft, yTop, xRight,
- yBottom" are the coordinates of the viewRect in the three-dimensional "world".
- "pen" is the three dimensional pen location. "penPrime" is the pen location
- transformed by the "xForm" matrix. "eye" is the position of the camera in
- three-dimensional coordinates. "hSize, vSize" are the half-width and half-
- height of the viewPort in screen coordinates. "hCenter, vCenter" are the
- coordinates of the center of the viewPort in screen coordinates. "xCotan,
- yCotan" are the cotangents of the horizontal and vertical viewing angles.
- "ident" is a boolean which is true when "xForm" is equal to the identity
- transformation. "xForm" is the transformation matrix.
-
- Port3DPtr = ^Port3D;
- Port3D = record
- GrPort : GrafPtr;
- viewRect : Rect;
- xLeft, yTop, xRight, yBottom : fixed;
- pen, penPrime, eye : Point3D;
- hSize, vSize : fixed;
- hCenter, vCenter : fixed;
- xCotan, yCotan : fixed;
- ident : BOOLEAN;
- xForm : XfMatrix;
- end;
-
-
-
-
- Graf3D Procedures and Functions
-
- Graf3D is a three dimensional Quickdraw package. Its types, variable and
- routines mimic Quickdraw in many ways. The following procedures and functions
- are provided in the Graf3D package:
-
- Graf3DPort port initialization routines:
-
- var thePort3D : Port3DPtr;
- procedure InitGrf3D (globalPtr : Ptr);
-
- InitGrf3D initializes the Graf3D drawing environment. This procedure should be
- called once and only once per program execution, after Quickdraw is initialized.
- "globalPtr" is a pointer to the storage you wish to use for the Graf3D global
- variables. Lightspeed Pascal programmers should always pass "@thePort3D" in
- this parameter.
-
- procedure Open3DPort (port : Port3DPtr);
- Open3DPort opens and initializes a 3D GrafPort whose space is pointed to by the
- parameter "port". It also sets "thePort3D" (the current Graf3DPort) to "port".
-
- procedure SetPort3D (port : Port3DPtr);
- SetPort3D sets the current Graf3DPort ("thePort3D") to "port" and calls SetPort
- for "port"'s associated grafPort.
-
- procedure GetPort3D (var port : Port3DPtr);
- GetPort3D returns a pointer to the current graf3DPort in "port". This is useful
- when the programmer wishes to change ports for drawing something and then
- restore the port before proceeding with the rest of the program. For example:
-
- var
- myPort, savePort: Port3DPtr;
- ..
- GetPort3D( savePort ); { save the current port }
- SetPort3D( myPort ); { set the port to my own }
- { I can do my drawing nowI }
- SetPort3D( savePort ); { restore the port to the one saved }
-
-
- Pen movement and drawing
-
- The following routines are used to move the pen in the 3D space and draw lines
- in the space. NOTE: The coordinates in these routines are specified in "fixed
- point" notation (NOT INTEGERS as in Quickdraw).
-
- procedure MoveTo2D (x, y : fixed);
- procedure MoveTo3D (x, y, z : fixed);
- These procedures move the pen to the designated coordinates. (MoveTo2D moves
- without changing the Z-coordinate.)
-
- procedure LineTo2D (x, y : fixed);
- procedure LineTo3D (x, y, z : fixed);
- These procedures draw lines from the current pen position to the given
- coordinates (LineTo2D draws without changing the z-coordinate, i.e. the line is
- drawn in the same z-plane.)
-
- procedure Move2D (dx, dy : fixed);
- procedure Move3D (dx, dy, dz : fixed);
- These procedures move the pen by the specified amounts relative to the current
- pen position. (Move2D moves without changing the Z-coordinate.)
-
- procedure Line2D (dx, dy : fixed);
- procedure Line3D (dx, dy, dz : fixed);
- These procedures draw lines from the current pen position to the given offsets
- relative to the current pen position (Line2D draws without changing the
- z-coordinate, i.e. the line is drawn in the same z-plane.)
-
- function Clip3D (src1, src2 : Point3D; var dst1, dst2 : POINT): boolean;
- Clip3D clips a three-dimensional line segment to the viewing pyramid and returns
- the clipped line projected onto screen coordinates. Clip3D returns true if any
- part of the line is visible.
-
- procedure SetPt3D ( var pt3D : Point3D; x, y, z : fixed);
- SetPt3D assigns the 3 fixed numbers "x,y,z" to the point pt3D.
-
- procedure SetPt2D ( var pt2D : Point2D; x, y : fixed);
- SetPt3D assigns the 2 fixed numbers "x,y" to the point pt2D.
-
-
- Setting up the point of view
-
- The following three procedures set the position and field-of-view of the "point
- of view".
-
- procedure LookAt (left, top, right, bottom : fixed);
- LookAt specifies the real number x,y coordinates of the viewing rectangle.
-
- procedure ViewPort (r : Rect);
- ViewPort specifies where to put the image in the grafPort. The ViewPort
- rectangle is specified in integer coordinates and tells where to map the LookAt
- coordinates.
-
- procedure ViewAngle (angle : fixed);
- ViewAngle controls the amount of perspective by specifying the horizontal angle
- subtended by the viewing rectangle. Typical ViewAngles are 0! (no perspective),
- 10! (telephoto lens), 25! (normal human eye), and 80! (wide angle lens).
-
-
- Transformation matrix procedures
-
- The following procedures modify the transformation matrix that is used to plot
- the points in the viewing coordinates.
-
- procedure Identity;
- Identity sets the transformation matrix to the identity matrix.
-
- procedure Scale (xFactor, yFactor, zFactor : fixed);
- Scale modifies the transformation matrix so as to shrink or expand the image by
- the factors specified.
-
- procedure Translate (dx, dy, dz : fixed);
- Transform modifies the transformation matrix so as to displace the image by the
- specified amounts in the three coordinates.
-
- procedure Pitch (xAngle : fixed);
- Pitch modifies the transformation matrix so as to rotate "xangle" degrees around
- the x axis. Positive values cause a clockwise rotation when looking at the
- origin from positive x.
-
- procedure Yaw (yAngle : fixed);
- Yaw modifies the transformation matrix so as to rotate "yAngle" degrees around
- the y axis. Positive values cause a clockwise rotation when looking at the
- origin from positive y.
-
- procedure Roll (zAngle : fixed);
- Roll modifies the transformation matrix so as to rotate "zAngle" degrees around
- the z axis. Positive values cause a clockwise rotation when looking at the
- origin from positive z.
-
- procedure Skew (zAngle : fixed);
- Skew modifies the transformation matrix so as to skew the image by "zAngle"
- degrees around the z axis. Skew only changes the x axis. Positive values cause
- a clockwise rotation when looking at the origin from positive z.
-
- procedure TransForm (src : Point3D; var dst : Point3D);
- Transform applies the transformation matrix to the "src" point, and returns the
- result in "dst".
-
-
-
- program boxes;
- uses
- Graf3D;
-
- const
- boxcount = 10;
-
- type
- box3d = record
- pt1 : Point3D;
- pt2 : point3D;
- dist : real;
- end;
-
- var
- GPort1 : GrafPort;
- GPort2 : Port3D;
- myPort : GrafPtr;
- myPort3D : Port3DPtr;
- boxArray : array[0..boxCount] of Box3D;
- nBoxes : integer;
- i : integer;
- ph : picHandle;
- r : rect;
-
- function HeapError (hz : QDPtr;
- bytesNeeded : integer) : integer;
- begin
- writeln('The heap is full!!!');
- end;
-
- function Distance (pt1, pt2 : Point3D) : real;
- var
- dx, dy, dz : real;
- begin
- dx := pt2.x - pt1.x;
- dy := pt2.y - pt1.y;
- dz := pt2.z - pt1.z;
- Distance := sqrt(dx * dx + dy * dy + dz * dz);
- end;
-
- procedure MakeBox;
- label
- 99;
- var
- myBox : Box3D;
- i, j, k, v : integer;
- p1, p2 : point3D;
- myRect : Rect;
- testRect : Rect;
- begin
- p1.x := (Random mod 140 - 85) * 65536;
- p1.y := (Random mod 140 - 80) * 65536;
- p1.z := 0;
- p2.x := p1.x + (10 + abs(Random) mod 30) * 65536;
- p2.y := p1.y + (10 + abs(Random) mod 45) * 65536;
- p2.z := p1.z + (10 + abs(Random) mod 35) * 65536;
- SetRect(myRect, round(p1.x div 65536), round(p1.y div 65536), round(p2.x div 65536), round(p2.y div 65536));
- for i := 1 to nBoxes - 1 do
- begin
- with boxArray[i] do
- SetRect(testRect, round(pt1.x DIV 65536), round(pt1.y DIV 65536), round(pt2.x DIV 65536), round(pt2.y DIV 65536));
- if sectrect(myRect, testRect, testRect) then
- goto 99;
- end;
- myBox.pt1 := p1;
- myBox.pt2 := p2;
- p1.x := (p1.x + p2.x) DIV 2;
- p1.y := (p1.y + p2.y) DIV 2;
- p1.z := (p1.z + p2.z) DIV 2;
- Transform(p1, p2);
- myBox.dist := Distance(p2, myPort3D^.eye);
- i := 0;
- boxArray[nBoxes].dist := myBox.dist;
- while myBox.dist > boxArray[i].dist do
- i := i + 1;
- for j := nBoxes downto i + 1 do
- boxArray[j] := boxArray[j - 1];
- boxArray[i] := myBox;
- nBoxes := nBoxes + 1;
- 99 :
- end;
-
- procedure drawBox (pt1, pt2 : Point3D);
- var
- tempRgn : RgnHandle;
- begin
- tempRgn := NewRgn;
- OpenRgn;
- MoveTo3D(pt1.x, pt1.y, pt1.z);
- LineTo3D(pt1.x, pt1.y, pt2.z);
- LineTo3D(pt2.x, pt1.y, pt2.z);
- LineTo3D(pt2.x, pt1.y, pt1.z);
- LineTo3D(pt1.x, pt1.y, pt1.z);
- CloseRgn(tempRgn);
- FillRgn(tempRgn, white);
- FrameRgn(tempRgn);
- OpenRgn;
- MoveTo3D(pt1.x, pt1.y, pt2.z);
- LineTo3D(pt1.x, pt2.y, pt2.z);
- LineTo3D(pt2.x, pt2.y, pt2.z);
- LineTo3D(pt2.x, pt1.y, pt2.z);
- LineTo3D(pt1.x, pt1.y, pt2.z);
- CloseRgn(tempRgn);
- FillRgn(tempRgn, gray);
- OpenRgn;
- MoveTo3D(pt2.x, pt1.y, pt1.z);
- LineTo3D(pt2.x, pt1.y, pt2.z);
- LineTo3D(pt2.x, pt2.y, pt2.z);
- LineTo3D(pt2.x, pt2.y, pt1.z);
- LineTo3D(pt2.x, pt1.y, pt1.z);
- CloseRgn(tempRgn);
- FillRgn(tempRgn, black);
- PenPat(white);
- MoveTo3D(pt2.x, pt2.y, pt2.z);
- LineTo3D(pt2.x, pt2.y, pt1.z);
- LineTo3D(pt2.x, pt1.y, pt1.z);
- PenNormal;
- DisposeRgn(tempRgn);
- end;
-
- begin
- setrect(r, 0, 40, 512, 342);
- SetDrawingRect(r);
- InitGrf3D(@thePort3D);
- showdrawing;
- GetPort(myPort);
- ph := OpenPicture(myPort^.portRect);
- showpen;
- myPort3D := @GPort2;
- Open3DPort(myPort3D);
- ViewPort(myPort^.portRect);
- LookAt($FF9C0000, $4B0000, $640000, $FFB50000);
- ViewAngle($200000);
- Identity;
- Roll($140000);
- Pitch($460000);
- PenPat(white);
- BackPat(black);
- EraseRect(myPort^.portRect);
- for i := -10 to 10 do
- begin
- MoveTo3D(i * 10 * 65536, -100 * 65536, 0);
- LineTo3D(i * 10 * 65536, 100 * 65536, 0);
- end;
- for i := -10 to 10 do
- begin
- MoveTo3D(-100 * 65536, i * 10 * 65536, 0);
- LineTo3D(100 * 65536, i * 10 * 65536, 0);
- end;
- nBoxes := 0;
- repeat
- MakeBox
- until nBoxes = boxCount;
- for i := nBoxes - 1 downto 0 do
- DrawBox(boxArray[i].pt1, boxArray[i].pt2);
- HidePen;
- ClosePicture;
- readln
- end.
- - --------
-
-
-
- I can't think of anything more politically correct than assasination...:)
- Segmentation Fault (core dumped)
-
- +++++++++++++++++++++++++++
-
- From: torello@alessia.dei.unipd.it (Tommaso Centro 310125/IF {*})
- Date: 13 Apr 92 10:16:01 GMT
- Organization: D.E.I.
-
- Is it possible to use Graf3D in color and how?
- Thanks
-
- Tom
-
- ---------------------------
-
- End of C.S.M.P. Digest
- **********************
-